<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">

<head lang="en">
    <meta charset="UTF-8">
    <title>智慧书坊</title>
    <link rel="stylesheet" type="text/css" th:href="@{/dist/css/bootstrap.min.css}">
    <link rel="stylesheet" type="text/css" th:href="@{/css/index.css}"/>
    <link rel="stylesheet" type="text/css" th:href="@{/css/animate.css}"/>
    <link rel="stylesheet" type="text/css" th:href="@{/css/login.css}"/>
    <link rel="stylesheet" th:href="@{/layui/css/layui.css}">

</head>

<body>
<!--导航部分  begin-->
<div th:replace="common/header :: nav"></div>
<!--导航部分 end-->

<!--最顶端轮播图片 begin-->
<div th:replace="common/carousel :: carousel"></div>
<!--最顶端轮播图片 end-->

<!--图书内容部分 begin-->
<div class="container">
    <!--文学类 begin-->
    <div>
        <div class="text-primary"><img src="images/bullet1.gif" th:src="@{/images/bullet1.gif}" alt="" title="">
            <a href="#">文学类</a>
        </div>
        <!--加载数据-->
        <div id="selected"></div>
    </div>
    <!--文学类 end-->

    <!--经管类 begin-->
    <div>
        <div class="text-primary"><img src="images/bullet1.gif" th:src="@{/images/bullet1.gif}" alt="" title="">
            <a href="#">经管类</a>
        </div>
        <div id="recommended"></div>
    </div>
    <!--经管类..-->

    <!--其他类 begin-->
    <div>
        <div class="text-primary"><img src="images/bullet1.gif" th:src="@{/images/bullet1.gif}" alt="" title="">
            <a href="#">其他类</a>
        </div>
        <div id="bargain"></div>
    </div>
    <!--其他 end-->
    <hr>
    <!--首页底部信息 begin-->
    <div th:replace="common/footer :: footer"></div>

</div>
<!--首页底部信息end-->
<!--图书内容部分end-->

<!-- 登录模态框（Modal） -->
<!-- 注册modal end/.modal -->
<div th:replace="common/bookModal :: bookModal"></div>

<script src="dist/js/jquery.min.js" th:src="@{/dist/js/jquery.min.js}"></script>
<script src="js/carousel.js" th:src="@{/js/carousel.js}" type="text/javascript" charset="utf-8"></script>
<script src="dist/js/bootstrap.min.js" th:src="@{/dist/js/bootstrap.min.js}"></script>
<script src="js/wow.js" th:src="@{/js/wow.js}"></script>
<script th:src="@{/js/login_reg.js}"></script>
<script th:src="@{/layui/layui.js}"></script>
<script th:inline="javascript">
    //获取应用路径
    var contextPath = [[${#request.getContextPath()}]];
</script>c
<script type="text/javascript">
    if (!(/msie [6|7|8|9]/i.test(navigator.userAgent))) {
        new WOW().init();
    }
    ;

    $(function () {
        $("#selected").load(contextPath + "/book/getBookData", buildQuery(1, 1));
        $("#recommended").load(contextPath + "/book/getBookData", buildQuery(1, 2));
        $("#bargain").load(contextPath + "/book/getBookData", buildQuery(1, 3));
    });

    //分页之加载上下页数据
    function loadData(page, category) {
        if (category == 1) {
            $("#selected").load(contextPath + "/book/getBookData", buildQuery(page, category));
        } else if (category == 2) {
            $("#recommended").load(contextPath + "/book/getBookData", buildQuery(page, category));
        } else if (category == 3) {
            $("#bargain").load(contextPath + "/book/getBookData", buildQuery(page, category));
        }
    };

    function buildQuery(page, category) {
        var query = {};
        query.page = typeof page == "undefined" ? 1 : page;
        query.category = category;
        return query;
    };

    //根据图书名搜索
    function searchBookName() {
        var inputBookName = $("#inputBookName").val();
        if (inputBookName != ''){
            window.location.href = contextPath + "/book/searchBook?inputBookName=" + inputBookName;
        }else layer.msg('查找内容不为空！', {icon: 7,anim:6});
    }

    //刷新验证码
    function refreshCode(){
        $("#mycode").attr("src","/book/getCode?time="+new Date().getTime());
    }

</script>
</body>

</html>